﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BLL;
using DAL;
using TTCN_QLDiemC3.MyUserControl.UCHienThi;
using TTCN_QLDiemC3.MyUserControl.UCMenu;

namespace TTCN_QLDiemC3
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void tabPage1_Click(object sender, EventArgs e)
        {

        }

        private void txtUserName_TextChanged(object sender, EventArgs e)
        {

        }

        private void btnDangNhap_Click(object sender, EventArgs e)
        {
            UCHome uchome = new UCHome();
            UCDanhSachChucNang ucds = new UCDanhSachChucNang();
            grbMenu.Controls.Clear();
            grbMenu.Controls.Add(uchome);
            grbHienThiChucNang.Controls.Clear();
            grbHienThiChucNang.Controls.Add(ucds);

            //try
            //{
            //    idnhanvien = userbuo.GetSingle(txtUsername.Text).id_NhanVien;
            //    UCHome uchome = new UCHome(idnhanvien);
            //    UCDanhSachChucNang ucds = new UCDanhSachChucNang(idnhanvien);
            //    if (userbuo.CheckUser(txtUsername.Text, txtPassword.Text))
            //    {
            //        MessageBox.Show(userbuo.GetSingle(txtUsername.Text).userName.ToString().Trim());
            //        grbMenu.Controls.Clear();
            //        grbMenu.Controls.Add(uchome);
            //        grbHienThiChucNang.Controls.Clear();
            //        grbHienThiChucNang.Controls.Add(ucds);

            //        //hiển thị các nút
            //        btnHome.Enabled = true;
            //        btnNhanSu.Enabled = true;
            //        btnKhachHang.Enabled = true;
            //        btnDonDatHang.Enabled = true;
            //        btnBanHang.Enabled = true;
            //        btnNCC.Enabled = true;
            //        btnThongKe.Enabled = true;
            //        btnNhapHang.Enabled = true;
            //        btnBanHang.Enabled = true;
            //        btnHangHoa.Enabled = true;
            //        btnBackupRestore.Enabled = true;

            //        //NguoiDung.userName = userbuo.GetSingle(txtUsername.Text).userName.ToString().Trim();
            //        //NguoiDung.idNhanVen = userbuo.GetSingle(txtUsername.Text).id_NhanVien.ToString().Trim();


            //    }
            //    else
            //    {
            //        lblThongBao.Text = "Sai username hoặc passwowrd";
            //    }
            //}
            //catch (Exception)
            //{

            //    lblThongBao.Text = "Sai username hoặc passwowrd";
            //}
        }

        private void pbHome_Click(object sender, EventArgs e)
        {
            UCHome home = new UCHome();
            UCDanhSachChucNang ds = new UCDanhSachChucNang();
            grbMenu.Controls.Clear();
            grbMenu.Controls.Add(home);
            grbHienThiChucNang.Controls.Clear();
            grbHienThiChucNang.Controls.Add(ds);

        }

        private void pbGiaoVien_Click(object sender, EventArgs e)
        {
            UCChucNangGiaoVien home = new UCChucNangGiaoVien();
            UCDanhSachGV ds = new UCDanhSachGV();
            grbMenu.Controls.Clear();
            grbMenu.Controls.Add(home);
            grbHienThiChucNang.Controls.Clear();
            grbHienThiChucNang.Controls.Add(ds);
        }

        private void pbHocSinh_Click(object sender, EventArgs e)
        {
            UCChucNangHocSinh home = new UCChucNangHocSinh();
            UCDanhSachHS ds = new UCDanhSachHS();
            grbMenu.Controls.Clear();
            grbMenu.Controls.Add(home);
            grbHienThiChucNang.Controls.Clear();
            grbHienThiChucNang.Controls.Add(ds);
        }

        private void pbMonHoc_Click(object sender, EventArgs e)
        {
            UCDanhSachMon home = new UCDanhSachMon();
            UCDanhSachMon ds = new UCDanhSachMon();
            grbMenu.Controls.Clear();
            grbMenu.Controls.Add(home);
            grbHienThiChucNang.Controls.Clear();
            grbHienThiChucNang.Controls.Add(ds);
        }

        private void pbLop_Click(object sender, EventArgs e)
        {
            UCChucNangLop home = new UCChucNangLop();
            UCDanhSachLop ds = new UCDanhSachLop();
            grbMenu.Controls.Clear();
            grbMenu.Controls.Add(home);
            grbHienThiChucNang.Controls.Clear();
            grbHienThiChucNang.Controls.Add(ds);
        }

        private void pbDiem_Click(object sender, EventArgs e)
        {
            UCChucNangBangDiem home = new UCChucNangBangDiem();
            UCBangDiem ds = new UCBangDiem();
            grbMenu.Controls.Clear();
            grbMenu.Controls.Add(home);
            grbHienThiChucNang.Controls.Clear();
            grbHienThiChucNang.Controls.Add(ds);
        }
    }
}
